<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>icf</title>

    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/public/layui/admin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/public/layui/admin/style/admin.css" media="all">
</head>

<body>

    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-header">订单发货</div>
            <div class="layui-card-body" style="padding: 15px;">
                <form class="layui-form" action="" lay-filter="component-form-group">
                    <input name="id" type="hidden" value="{{ data.orderId }}" />



                    <div class="layui-tab layui-tab-card">

                        <ul class="layui-tab-title">
                            <li class="layui-this">订单发货</li>
                        </ul>

                    </div>
                    <div class="layui-tab-content" style="height: 100px;">
                        <div class="layui-tab-item layui-show">
                            <div class="layui-form-item">
                                <label class="layui-form-label">物流公司</label>
                                <div class="layui-input-block">
                                    <input type="hidden" name="logisticsId" id="logisticsId">
                                    <select name="logisticsCompanys" id="logisticsCompanys" lay-verify="required">
                                    </select>

                                </div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label">物流单号</label>
                                <div class="layui-input-block">
                                    <input type="text" id="LogisticsNo" name="LogisticsNo" lay-verify="title"
                                        autocomplete="off" placeholder="" class="layui-input" readonly>
                                </div>
                            </div>

                        </div>

                    </div>

                    <div class="layui-form-item layui-layout-admin">
                        <div class="layui-input-block">
                            <div class="layui-footer" style="left: 0;">
                                <button class="layui-btn" lay-submit="" lay-filter="edit-submit">提交</button>
                                <a href="javascript:goBack()" class="layui-btn layui-btn-primary">返回</a>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>


    <script src="/public/layui/admin/layui/layui.js"></script>
    <script>
        layui.config({
            base: '/public/layui/admin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form', 'laydate', 'jquery', 'upload'], function () {
            var $ = layui.$,
                admin = layui.admin,
                element = layui.element,
                layer = layui.layer,
                laydate = layui.laydate,
                form = layui.form;

            form.render(null, 'component-form-group');
            laydate.render({
                elem: '#LAY-component-form-group-date'
            });

            /* 自定义验证规则 */
            form.verify({
                title: function (value) {
                    if (value.length < 0) {
                        return '请输入';
                    }
                },
                pass: [/(.+){6,12}$/, '密码必须6到12位'],
                content: function (value) {
                    layedit.sync(editIndex);
                }
            });



            /* 监听提交 */
            form.on('submit(edit-submit)', function (data) {
                // parent.layer.alert(JSON.stringify(data.field), {
                //   title: '最终的提交信息'
                // })

                var requestData = {
                    id = $("#id").val(),
                    logistics_id = $("#logisticsCompanys").val(),
                    logistics_no = $("#LogisticsNo").val()
                };

                $.ajax({
                    type: "POST",
                    url: "/admin/sysOders/SysOrders/delivery_saas?appid={{data.Who.MiniAppId}}&tid={{data.Who.TenantId}}",
                    data: JSON.stringify(requestData),
                    async: true,
                    dataType: 'JSON',
                    contentType: 'application/json',
                    error: function (request) {
                        parent.layer.alert(JSON.stringify(request), {
                            title: '操作失败'
                        });
                    },
                    success: function (response) {
                        console.log(response);
                        //var rt = JSON.parse(response);
                        var rt = response
                        if (rt.code == 0) {
                            var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                            parent.layer.close(index);
                        } else {
                            parent.layer.alert(rt.msg, {
                                title: '操作失败'
                            });
                        }
                    }
                });
                return false;
            });


            init();

            function init() {
                $.ajax({
                    type: "Get",
                    url: "/admin/sysOrders/SysLogisticsCompany/listselectjson_saas" +
                        '?appid={{data.Who.MiniAppId}}&tid={{data.Who.TenantId}}',
                    async: true,
                    error: function (request) {
                        parent.layer.alert(JSON.stringify(request), {
                            title: '操作失败'
                        });
                    },
                    success: function (response) {
                        var logisticsCompanys = $("#logisticsCompanys");
                        shop_logisticsCompanysist.empty();
                        logisticsCompanys.append("<option value=\"0\">请选择物流公司</option>");
                        for (var i = 0; i < response.data.length; i++) {

                            logisticsCompanys.append("<option value=\"" + response.data[i].Id +
                                "\">" +
                                response.data[i].CompanyName + "</option>");

                        }
                        form.render();
                    }
                });
            }

            /* 监听指定开关
            form.on('switch(component-form-switchTest)', function(data){
              layer.msg('开关checked：'+ (this.checked ? 'true' : 'false'), {
                offset: '6px'
              });
              layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
            });*/
        });

        // 页面返回上一页面
        function goBack() {
            var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
            parent.layer.close(index);
        };
    </script>
</body>

</html>